package com.andybest.search.timer;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.andybest.search.dto.ItemDto;
import com.andybest.search.dto.TaskInfo;
import com.andybest.search.util.ExcuteTask;

public class MoniterTask extends Thread {
	public void run() {
		// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

		while (true) {
			// Date current = new Date();
			// System.out.println(sdf.format(current));
			for (int i = 0; i < TaskListManager.getTaskList().size(); i++) {
				try {
					TaskInfo currentTask = (TaskInfo) TaskListManager
							.getTaskList().get(i);
					if (currentTask.isActive()) {
						Thread.sleep(1000*2);
						ItemDto itemDto = ExcuteTask.doExcuteTask(currentTask);
						if(itemDto != null){
							System.out.println(itemDto);
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

}
